<p>&nbsp;</p>
<div align="center">
  <h1>ตารางกรอกข้อมูลคุณภาพสินค้า Final Check</h1>
</div>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
  <tr>
    <td width="12%" height="30">Date</td>
    <td width="27%" height="30"> :
      <input id="datepicker" data-bind="value: departure" /></td>
    <td width="18%" height="30">Product</td>
    <td width="43%" height="30"> :
      <select name="ticket" class="select" id="ticket3">
        <option value="N">N</option>
        <option value="S">S</option>
        <option value="N/C">N/C</option>
        <option value="ETC">ETC</option>
      </select></td>
  </tr>
  <tr>
    <td height="30">Order</td>
    <td height="30"> :
      <input type="text" id="Order" class="k-textbox"/></td>
    <td height="30">หมายเลขทะเบียนรถขนส่ง</td>
    <td height="30"> :
      <input name="textfield20" type="text" class="k-textbox" id="numbercar"/></td>
  </tr>
  <tr>
    <td height="30">Order No.</td>
    <td height="30"> :
      <select name="ticket5" class="select" id="ticket1">
        <option value="หัว">หัว</option>
        <option value="กลาง">กลาง</option>
        <option value="ท้าย">ท้าย</option>
      </select></td>
    <td height="30">Grade</td>
    <td height="30"> :
      <select name="ticket2" class="select" id="ticket4">
        <option value="N">N</option>
        <option value="S">S</option>
        <option value="N/C">N/C</option>
        <option value="ETC">ETC</option>
      </select></td>
  </tr>
  <tr>
    <td height="30">Total Pallet</td>
    <td height="30"> :
      <select name="ticket3" class="select" id="ticket2">
        <option value="N">N</option>
        <option value="S">S</option>
        <option value="N/C">N/C</option>
        <option value="ETC">ETC</option>
      </select></td>
    <td height="30">Problem</td>
    <td height="30"> :
      <input name="textfield21" type="text" class="k-textbox" id="Problem"/></td>
  </tr>
  <tr>
    <td height="30">Customer</td>
    <td height="30"> :
      <input name="textfield2" type="text" class="k-textbox" id="Customer"/></td>
    <td height="30">&nbsp;</td>
    <td height="30">&nbsp;</td>
  </tr>
</table>
<br />
<table width="60%" align="center">
  <tr>
    <td><div align="right">
 
<centeR><span id="loading"></span></center><input name="Submit" type="submit" class="k-button" id="submit" value="บันทึกข้อมูล"/>
&nbsp;
<input name="Reset" type="submit" class="k-button" value="ยกเลิก"/>
</div></td>
  </tr>
</table>
<table width="60%" align="center" class="font">
  <tr>
    <td><table id="grid">
        <thead>
          <tr>
            <th data-field="Properties">Properties Item</th>
            <th data-field="Value1">Value</th>
            <th data-field="Value2">Value</th>
            <th data-field="Unit">Unit</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>สภาพตั้งกระดาษก่อนแกะ Flim ออกตรวจสอบ</td>
            <td><input name="fc10_1" type="number" value="0" class="k-textbox number" id="fc10_1"/></td>
            <td><input name="fc10_2" type="number" class="k-textbox number" id="fc10_2" value="0"/></td>
            <td>ppm.</td>
          </tr>
          <tr>
            <td>การพัน Flim รอบตั้ง</td>
            <td><input name="fc11_1" type="number" value="0" class="k-textbox number" id="fc11_1"/></td>
            <td><input name="fc11_2" type="number" class="k-textbox number" id="fc11_2" value="0"/></td>
            <td>แผ่น</td>
          </tr>
          <tr>
            <td>สายรัดยึดแผ่น MDF   พาเลทและกล่อง</td>
            <td><input name="fc12_1" type="number" value="0" class="k-textbox number" id="fc12_1"/></td>
            <td><input name="fc12_2" type="number" class="k-textbox number" id="fc12_2" value="0"/></td>
            <td>No.</td>
          </tr>
          <tr>
            <td>สภาพกล่องหลังจากแกะFlim และสายรัดพาเลทออก</td>
            <td><input name="fc13_1" type="number" value="0" class="k-textbox number" id="fc13_1"/></td>
            <td><input name="fc13_2" type="number" class="k-textbox number" id="fc13_2" value="0"/></td>
            <td>1=Long grain,2=Shot grain</td>
          </tr>
          <tr>
            <td>สายรัดกล่อง</td>
            <td><input name="fc14_1" type="number" value="0" class="k-textbox number" id="fc14_1"/></td>
            <td><input name="fc14_2" type="number" class="k-textbox number" id="fc14_2" value="0"/></td>
            <td>แผ่น</td>
          </tr>
          <tr>
            <td>สภาพกล่องและฝาขณะยกออกจากพาเลทเพื่อตรวจสอบ</td>
            <td><input name="fc15_1" type="number" value="0" class="k-textbox number" id="fc15_1"/></td>
            <td><input name="fc15_2" type="number" class="k-textbox number" id="fc15_2" value="0"/></td>
            <td>mm.</td>
          </tr>
          <tr>
            <td>สภาพ Pallet หลังจากยกกล่องออกตรวจสอบ</td>
            <td><input name="fc16_1" type="number" value="0" class="k-textbox number" id="fc16_1"/></td>
            <td><input name="fc16_2" type="number" class="k-textbox number" id="fc16_2" value="0"/></td>
            <td>mm.</td>
          </tr>
        </tbody>
      </table>
    <script>
                $(document).ready(function() {
                    $("#grid").kendoGrid({
						columns: [
						{ field: "Properties", width: "100px" },
						{ field: "Value1", width: "20px" },
						{ field: "Value2", width: "20px" },
						{ field: "Unit",  width: "40px" }
						],
                        //height: 1000,
						//pageable: true,
						dataSource: {
						//pageSize: 12
						} 
                    });
                });
            </script></td>
  </tr>
</table>

<!--scrip list select--> 
<script>
                $(document).ready(function() {
                    var viewModel = {
                        chosenTicket: ko.observable(),
                        resetTicket: function() { this.chosenTicket(null) },
                    };
                    $("#ticket1").kendoDropDownList().trigger("change");
                    $("#ticket2").kendoDropDownList().trigger("change");
                    $("#ticket3").kendoDropDownList().trigger("change");
                    $("#ticket4").kendoDropDownList().trigger("change");
                });
      		</script> 
<!--scrip วัน-เดือน-ปี--> 
<script>
                $(document).ready(function() {
                    var today = new Date(),
                        birthdays = [
                           +new Date(today.getFullYear(), today.getMonth(), 11),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 6),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 27),
                           +new Date(today.getFullYear(), today.getMonth() - 1, 3),
                           +new Date(today.getFullYear(), today.getMonth() - 2, 22)
                        ];

                    $("#datepicker").kendoDatePicker({
                        value: today,
                        month: {
                            // template for dates in month view
                            content: '# if ($.inArray(+data.date, [' + birthdays + ']) != -1) { #' +
                                         '<div class="birthday"></div>' +
                                     '# } #' +
                                     '#= data.value #'
                        },
                        footer: "Today - #=kendo.toString(data, 'd') #"
                    });

                    $("#datepicker").data("kendoDatePicker")
                                    .dateView.calendar.element
                                    .width(300);
                });
            </script> 
<!--scrip เวลา--> 
			<script>
                $(document).ready(function() {
                    // create TimePicker from input HTML element
                    $("#timepicker").kendoTimePicker();
                });
            </script>
            <script>
					$("#submit").click(function(){
					     var finalcheckFC1 = $("#datepicker").val();
                         var finalcheckFC2 = $("#Order").val(); 
                         var finalcheckFC3 = $("#ticket1").val();  
                         var finalcheckFC4 = $("#ticket2").val();  
                         var finalcheckFC5 = $("#Customer").val(); 
                         var finalcheckFC6 = $("#ticket3").val();
                         var finalcheckFC7 = $("#numbercar").val();
                         var finalcheckFC8 = $("#ticket4").val(); 
                         var finalcheckFC9 = $("#Problem").val();
						 <?php 
                         	for($i=10;$i<=16;$i++){
                         		
                         	echo "var finalcheckFC".$i."_1 = $(\"#fc".$i."_1\").val(); \n";
                         	echo "var finalcheckFC".$i."_2 = $(\"#fc".$i."_2\").val(); \n";	
                         	}
                         ?>  
                    if (confirm("ต้องการจะบันทึกข้อมูลหรือไม่ ?")) 
                        { 
		      //alert('<1>==>'+finalcheckFC1+'<2>==>'+finalcheckFC2+'<3>==>'+finalcheckFC3+'<4>==>'+finalcheckFC4+'<5>==>'+finalcheckFC5+'<6>==>'+finalcheckFC6+'<7>==>'+finalcheckFC7+'<8>==>'+finalcheckFC8+'<9>==>'+finalcheckFC9+'<10_1>==>'+finalcheckFC10_1+'<10_>==>'+finalcheckFC10_2);
			  var loading = "<img src='<?=base_url(); ?>css/BlueOpal/loading-image.gif?>'>";
		      $.ajax({
		      url : "<?php echo base_url();?>index.php/finalcheck/newDataFinalCheck",
		      type: "POST",
		      data:({  
			  finalcheckFC2 : finalcheckFC2,
			  finalcheckFC3 : finalcheckFC3,
			  finalcheckFC4 : finalcheckFC4,
			  finalcheckFC5 : finalcheckFC5,
			  finalcheckFC6 : finalcheckFC6,
			  finalcheckFC7 : finalcheckFC7,
			  finalcheckFC8 : finalcheckFC8,
			  finalcheckFC9 : finalcheckFC9,
			  <?php 
			  for($i=10;$i<=16;$i++){
			  echo "finalcheckFC".$i."_1 : finalcheckFC".$i."_1, \n";
			  echo "finalcheckFC".$i."_2 : finalcheckFC".$i."_2, \n";
			  }?> 
			  finalcheckFC1 : finalcheckFC1
		        	}),
				beforeSend : function()
				{
		        $("#loading").html(loading);
		        //$("#overlay").css('display','block'); // displaying the overlay
		        // jQuery("#popup").css('display','block'); // displaying the popup
		        //$("#submit").attr("disabled","disabled");
		        },
		        success : function(rs)
				{
		        alert(rs);
		        $("#loading").html('');
		        //$("#submit").removeAttr("disabled","disabled");
				<?php 
		        for($i=10;$i<=16;$i++){
		        echo " $(\"#fc".$i."_1\").val('0'); \n";
		        echo "  $(\"#fc".$i."_2\").val('0'); \n";	
		        }
		        ?> 
				}						
				})
				}
		        });
            </script>
